﻿#region 版权信息
// ------------------------------------------------------------------------------
// Copyright: (c) 2029  耍嗨科技（成都）有限公司 - Amm
// 项目名称：$SOLUTION/$.Amm.Common
// 文件名称：GuidExtensions.cs
// 创建时间：2020093011:17
// 更改时间：2020093011:17
//  ------------------------------------------------------------------------------
#endregion

using System;

namespace Colorful.Furniture.Extensions
{
    public static class GuidExtensions
    {
        /// <summary>
        /// 判断Guid是否为空
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static bool IsNull(this Guid s)
        {
            return s == Guid.Empty;
        }

        /// <summary>
        /// 判断Guid是否为空
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static bool IsNull(this Guid? s)
        {
            return s == Guid.Empty || !s.HasValue;
        }

        /// <summary>
        /// 判断Guid是否不为空
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static bool NotNull(this Guid s)
        {
            return s != Guid.Empty;
        }

        /// <summary>
        ///  转换成字符串
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string ToDefaultStr(this Guid? s)
        {
            return s.HasValue ? s.ToString() : "";
        }
    }
}